/*
package com.aida.evil.eda.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.aida.evil.aida.R;
import com.aida.evil.eda.Adapter.CommonAdapter;
import com.aida.evil.eda.Adapter.ViewHolder;
import com.aida.evil.eda.Data.NetworkData;
import com.aida.evil.eda.Data.UserData;
import com.aida.evil.eda.Network.Eda_item_network;
import com.aida.evil.eda.Volley.VolleyHandler;
import com.aida.evil.eda.Volley.VolleyHttpRequest;
import com.squareup.picasso.Picasso;
import com.yalantis.phoenix.PullToRefreshView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

*/
/****************************************************
 * com.aida.evil.eda.fragment.Eda
 * 作者：白雨濃  evil
 * 时间：16-2-11 21:42
 * 邮箱：evilbai@foxmail.com
 * 页面用途：主界面 首页 界面fragment
 * 包含 首页ListView的Adapter和ItemBean
 * 继承于Eda_item_network，进行网络框架加载，Eda_item_network继承了Fragment
 ****************************************************//*

public class Eda111 extends Eda_item_network
{
    private int m_页面容纳的Item = 0;//页面当前的item数量
    private static final int m_页面容纳的最大Item = 5;
    private static final int m_刷新时间 = 1000;
    private static int LastItemID = 0;

    private SharedPreferences sharedPreferences;

    private View view;*/
/*每个list里面的view*//*

    private ListView listView;*/
/*listview列表*//*

    private Eda_Adapter adapter;*/
/*适配器*//*


    private ArrayList<Eda_ItemBeans> eda_items = new ArrayList<>();
    //private List<Integer> firstitemid_list = new ArrayList<>();

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        sharedPreferences = this.getContext().
                getSharedPreferences("lastitemid", Context.MODE_PRIVATE);
        firstLoad();*/
/*首次加载*//*

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        view = inflater.inflate(R.layout.mainactivity_fragment_eda, container, false);
        listView = (ListView) view.findViewById(R.id.mainactivity_fragment_eda_listview);
        //listView.setVisibility(View.GONE);
        //ProgressBar progressBar= (ProgressBar) view.findViewById(R.id.mainactivity_fragment_eda_progressBar);
        //progressBar.setVisibility(View.GONE);

        // toNetwork();//预读
        adapter = new Eda_Adapter(getContext(), eda_items, R.layout.mainactivity_fragment_eda_listview_item);
        //adapter = new Eda_Adapter();
        listView.setAdapter(adapter);

        m_item选择跳转();
        m_下拉刷新();

        return view;
    }

    */
/**
     * 首次加载
     *//*

    private void firstLoad()
    {
        int firstLastItemID;
        int date = 0;

        String[] s = UserData.DATA_LASTITEMID.split("");
        if (s.length > 8)
        {
            date = Integer.valueOf(UserData.DATA_LASTITEMID) / 1000;//获取itemid的前缀，因为前缀是日期，固定的
            int length = s.length;
            firstLastItemID =
                    Integer.valueOf(s[length - 3]) * 100
                            + Integer.valueOf(s[length - 2]) * 10
                            + Integer.valueOf(s[length - 1]);
            Log.i("firstLastItemID", date + "   " + firstLastItemID);
        }
        else
        {
            firstLastItemID = 0;
        }

        //比旧的还旧的
        if (firstLastItemID - m_页面容纳的最大Item * 2 > 0)
        {
            firstLastItemID = firstLastItemID - m_页面容纳的最大Item * 2;
            toNetwork(date * 1000 + firstLastItemID - m_页面容纳的最大Item);
            Log.i("比旧的还旧的", date + "   " + firstLastItemID);
        }
        //这是加载上一次的旧的
        else
        {
            if (firstLastItemID - m_页面容纳的最大Item > 0)
            {
                firstLastItemID = firstLastItemID - m_页面容纳的最大Item;
                Log.i("旧的", date + "   " + firstLastItemID);
            }
        }
        //加载新的
        Log.i("首次加载", date + "   " + firstLastItemID);
        toNetwork(date * 1000 + firstLastItemID);
    }

    private void m_item选择跳转()
    {
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener()
        {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id)
            {
                //eda_items_buff = new ArrayList<>();
                //Eda_ItemBeans eda_itemBeans = eda_items.get(position);
                eda_items.remove(position);
                ArrayList<Eda_ItemBeans> eda_itemBeanses = new ArrayList<Eda_ItemBeans>();
                eda_itemBeanses.addAll(eda_items);
                eda_items.clear();
                eda_items.addAll(eda_itemBeanses);
                //eda_items_buff.addAll(eda_items);
                adapter.notifyDataSetChanged();//
                Log.i("更新", "更新5");
                //listView.setAdapter(adapter);
                */
/*Intent intent = new Intent(getActivity(), AnswerActivity.class);
                intent.putExtra("item标题", eda_itemBeans.getTitle());
                intent.putExtra("itemID", eda_itemBeans.getItemId());
                startActivity(intent);
                getActivity().overridePendingTransition(R.anim.in_from_right, R.anim.out_from_left);*//*

            }
        });

    }

    */
/**
     * 下拉刷新
     * 可以设置刷新时间默认1s，如果网络加载成功，刷新结束，未成功，则再次re
     *//*

    private void m_下拉刷新()
    {
        pullToRefreshView =
                (PullToRefreshView) view.findViewById
                        (R.id.mainactivity_fragment_eda_PullToRefreshView);
        pullToRefreshView.setOnRefreshListener(new PullToRefreshView
                .OnRefreshListener()
        {
            @Override
            public void onRefresh()
            {
                pullToRefreshView.postDelayed(new Runnable()
                {
                    @Override
                    public void run()
                    {
                        pullToRefreshView.setRefreshing(true);//默认为重复刷新，加载成功后，设置成false，停止刷新
                        toNetwork(LastItemID);
                        //protected void Responselistener(String 请求手机的IMEI, int Item条数)

                    }
                }, m_刷新时间);
            }
        });

    }

    */
/**
     * 抽象类，用于监听网络加载成功后所要干的事情
     *
     * @param IMEI     请求手机的IMEI号
     * @param ItemNUM  一次返回的Item的条数
     * @param ItemList 此次返回Item的全部内容
     *//*

    @Override
    protected void Responselistener(String IMEI, int ItemNUM, List<Item内容> ItemList)
    {
        */
/**
         * 判断当前页面的item数目是否超过最大限度，超过最大限度的话，移除底下的item
         *//*

        if (m_页面容纳的Item > m_页面容纳的最大Item)
        {
            //移除item，移除最下面的item，指针值为eda_items的大小减去1，新添加了多少个，移除多少个
            for (int i = 0; i < ItemNUM; i++)
            {
                eda_items.remove(eda_items.size() - 1);
            }
            Item内容 item内容 = null;
            for (int i = 0; i < ItemNUM; i++)
            {
                item内容 = ItemList.get(i);
                int ItemId = item内容.getItemID();//根据Id获取图片
                eda_items.add(0, new Eda_ItemBeans(R.mipmap.ic_launcher, ItemId, item内容.getItemTitle(), item内容.getItemContext()));
            }
            LastItemID = item内容.getItemID();//得到最后一个Item的ID，传递给服务器，服务器根据此Id向下给用户传递
        }
        else
        {
            Item内容 item内容 = null;
            for (int i = 0; i < ItemNUM; i++)
            {
                item内容 = ItemList.get(i);
                int ItemId = item内容.getItemID();//根据Id获取图片
                //Log.i("ItemId", "" + ItemId);
                eda_items.add(0, new Eda_ItemBeans(R.mipmap.ic_launcher, ItemId, item内容.getItemTitle(), item内容.getItemContext()));
            }
            LastItemID = item内容.getItemID();//得到最后一个Item的ID，传递给服务器，服务器根据此Id向下给用户传递
            m_页面容纳的Item = m_页面容纳的Item + ItemNUM;
        }
        //listView.setAdapter(new Eda_Adapter(getContext(), eda_items, R.layout.mainactivity_fragment_eda_listview_item));
        listView.setAdapter(new Eda_Adapter(getContext(), eda_items, R.layout.mainactivity_fragment_eda_listview_item));
    }


    @Override
    public void onStop()
    {
        super.onStop();
        finishload();
    }

    */
/**
     * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
     * 结束加载
     *//*


    private void finishload()
    {
        String url = "http://" + NetworkData.ServiceIP + "/UserData?";

        VolleyHandler<String> stringVolleyHandler = new VolleyHandler<String>()
        {
            @Override
            public void reqSuccess(String response)
            {

            }

            @Override
            public void reqError(String error)
            {

            }
        };

        Map<String, String> map = new HashMap<>();
        map.put("userIMEI", "" + UserData.DATA_用户IMEI);
        map.put("LastItemID", "" + LastItemID);
        Log.i("最后", "" + LastItemID);
        VolleyHttpRequest.String_request(url, map, stringVolleyHandler);
    }

    */
/**
     * >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
     * 私有内部类
     *//*

  */
/*  private class Eda_Adapter extends BaseAdapter
    {
        private LayoutInflater layoutInflater = LayoutInflater.from(getContext());

        @Override
        public int getCount()
        {
            return eda_items.size();
        }

        @Override
        public Object getItem(int position)
        {
            return eda_items.get(position);
        }

        @Override
        public long getItemId(int position)
        {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent)
        {

            //实例化ViewHolder
            Eda_ViewHolder viewHolder = new Eda_ViewHolder();
            if (convertView == null)//如果 convertView为空   View未被实例化缓存池中无缓存
            {
                //如果为空，创建一个新的布局后加载资源，不为空直接加载资源
                convertView = layoutInflater.inflate(R.layout.mainactivity_fragment_eda_listview_item, null);

                viewHolder.imageView = (ImageView) convertView.findViewById(R.id.eda_listview_item_imageView);
                viewHolder.title = (TextView) convertView.findViewById(R.id.eda_listview_item_title);
                viewHolder.context = (TextView) convertView.findViewById(R.id.eda_listview_item_context);

                convertView.setTag(viewHolder);//如果没有，将convertView设置进入Tag标签

            }
            //如果有，直接通过Tag取出
            viewHolder = (Eda_ViewHolder) convertView.getTag();

            Eda_ItemBeans itemBean = eda_items.get(position);//从List中取出指定位置position，存入ItemBean（List是ItemBean集合）

            *//*
*/
/*Picasso.with(getContext())
                    .load(imgurl + itemBean.getItemId())
                    .placeholder(R.mipmap.loading)
                    .error(itemBean.getImageView())
                    .into(viewHolder.imageView);*//*
*/
/*
            viewHolder.title.setText("sdaffsd");
            viewHolder.context.setText("sdaffsd");


            return convertView;
        }
    }

    private class Eda_ViewHolder
    {
        protected ImageView imageView;
        protected TextView title;
        protected TextView context;
    }*//*










    private class Eda_Adapter extends CommonAdapter<Eda_ItemBeans>
    {
        private Context context;


        public Eda_Adapter(Context context, List<Eda_ItemBeans> itemBean_list, int itemLayoutResId)
        {
            super(context, itemBean_list, itemLayoutResId);
            this.context = context;
        }


        @Override
        public void convert(ViewHolder viewHolder, Eda_ItemBeans item)
        {
            ImageView imageView = viewHolder.getView(R.id.eda_listview_item_imageView);
            TextView title = viewHolder.getView(R.id.eda_listview_item_title);
            TextView context = viewHolder.getView(R.id.eda_listview_item_context);

            Picasso.with(this.context)
                    .load(IMGURL + item.getItemId())
                    .placeholder(R.mipmap.loading)
                    .into(imageView);

            title.setText(item.getTitle());
            context.setText(item.getContext());

        }

    }

    private class Eda_ItemBeans
    {
        private int imageView;
        private int itemId;
        private String title;
        private String context;

        public Eda_ItemBeans(int imageView, int itemId, String title, String context)
        {
            this.imageView = imageView;
            this.itemId = itemId;
            this.title = title;
            this.context = context;
        }

        public int getItemId()
        {
            return itemId;
        }

        public void setItemId(int itemId)
        {
            this.itemId = itemId;
        }

        public int getImageView()
        {
            return imageView;
        }

        public void setImageView(int imageView)
        {
            this.imageView = imageView;
        }

        public String getTitle()
        {
            return title;
        }

        public void setTitle(String title)
        {
            this.title = title;
        }

        public String getContext()
        {
            return context;
        }

        public void setContext(String context)
        {
            this.context = context;
        }
    }

}


*/
